package com.service.imple.home;

import com.dao.NewsMapper;
import com.entity.GoodsCatalog;
import com.entity.News;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.home.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class NewsServiceImple implements NewsService {

    @Autowired
    private NewsMapper newsMapper;

    @Override
    public PageInfo<News> selectByPage(Map<String, Object> param) {
        int pageNum=Integer.parseInt(param.get("pageNum").toString());
        PageHelper.startPage(pageNum,6);
        List<News> list = newsMapper.selectAll(param);
        PageInfo<News> info =new PageInfo<>(list);
        return info;
    }

    @Override
    public List<News> select(Map map) {
        return newsMapper.selectAll(map);
    }

    @Override
    public int insert(News news) {
        return newsMapper.insert(news);
    }

    @Override
    public int update(News news) {
        return newsMapper.updateByPrimaryKey(news);
    }

    @Override
    public int delete(int id) {
        return newsMapper.deleteByPrimaryKey(id);
    }
}
